﻿@model RoadFlow.Model.ProgramButton
<form id="form1" method="post">
    @Html.AntiForgeryToken()
    <div>
        <input type="hidden" name="Id" value="@Model.Id" />
        <input type="hidden" name="ProgramId" value="@Model.ProgramId" />
        <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable" style="margin-top:10px;">
            <tr>
                <th style="width: 80px;">按钮名称：</th>
                <td><input type="text" validate="empty" class="mytext" name="ButtonName" id="ButtonName" value="@Model.ButtonName" /></td>
            </tr>
            <tr>
                <th style="width: 80px;">执行脚本：</th>
                <td>
                    <textarea class="mytextarea" validate="empty" style="width: 80%; height: 60px;" id="ClientScript" name="ClientScript">@Model.ClientScript</textarea>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">图标：</th>
                <td>
                    <input type="text" class="myico" name="Ico" id="Ico" value="@Model.Ico" />
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">按钮类型：</th>
                <td>
                    <select class="myselect" id="ShowType" name="ShowType">
                        <option value="1" @(Model.ShowType == 1 ? "selected=\"selected\"" : "")>普通按钮</option>
                        <option value="0" @(Model.ShowType == 0 ? "selected=\"selected\"" : "")>工具栏按钮</option>
                        <option value="2" @(Model.ShowType == 2 ? "selected=\"selected\"" : "")>列表按键</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">权限控制：</th>
                <td>
                    <select class="myselect" id="IsValidateShow" name="IsValidateShow">
                        <option value="1" @(Model.IsValidateShow==1?"selected=\"selected\"":"")>控制</option>
                        <option value="0" @(Model.IsValidateShow==0?"selected=\"selected\"":"")>不控制</option>
                    </select> *如果不控制则不需要授权,每个人都能操作此按钮
                </td>
            </tr>
            <tr>
                <th style="width: 80px;">显示顺序：</th>
                <td><input type="text" class="mytext" id="Sort" name="Sort" value="@Model.Sort" /></td>
            </tr>
        </table>
    </div>
    <div class="buttondiv">
        <input type="button" value=" 保 存 " class="mybutton" onclick="save(this);" />
        <input type="button" class="mybutton" onclick="window.location = 'Set_Button@(Html.Raw(ViewData["queryString"]))';" value=" 返 回 " />
    </div>
</form>
<script type="text/javascript">
    function save(but) {
        var f = document.forms[0];
        if(new RoadUI.Validate().validateForm(f)){
            var o = RoadUI.Core.serializeForm($(f));
            $(but).prop("disabled", true);
            $.ajax({url:"SaveSet_Button@(Html.Raw(ViewData["queryString"]))", data:o, type:"post", success:function (text) {
                alert(text);
                $(but).prop("disabled", false);
                if(text.indexOf('成功')>=0) {
                    window.location="Set_Button@(Html.Raw(ViewData["queryString"]))";
                }
            }});
        }
    }
</script>
